home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group00b.txt
/
000137_icon-group-sender_Thu Nov 2 07:58:06 2000.msg
< prev
next >
Wrap
Internet Message Format
|
2001-01-03
|
4KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id eA2Etn608361
for icon-group-addresses; Thu, 2 Nov 2000 07:55:49 -0700 (MST)
Message-Id: <200011021455.eA2Etn608361@baskerville.CS.Arizona.EDU>
From: "Ian Trudel" <ian.trudel@tr.cgocable.ca>
To: <Chris.D.Tenaglia@jci.com>, <icon-group@cs.arizona.edu>
Subject: CGI Programming (was: favorites)
Date: Wed, 1 Nov 2000 20:29:08 -0500
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 3359
Speaking of this, we're doing a lot of CGI programming using Icon at Mecenia
Organization. I've been updating cgi.icn and we will probably release a new
updated version soon, having some bug fixes and support for cookies, custom
header/footer/stylesheet and so forth. We will probably update
http://ringer.cs.utsa.edu/research/icon/cgi.html (if Clinton Jefferey and
Jonathan Vallejo don't mind) as well. If you have code snipet you'd like to
add, just drop me an email.
regards,
ian
----------------------------------------------------------------
*squeak* *squeak* said the little mouse while eating a java hog.
Ian Trudel, mailto:ian.trudel@tr.cgocable.ca
----- Original Message -----
From: <Chris.D.Tenaglia@jci.com>
To: <icon-group@CS.Arizona.EDU>
Sent: Tuesday, October 31, 2000 5:29 PM
Subject: favorites
> Since this list is getting more active here are some of my favorite
> procedures.
> The IPL is full of goodies. Some below may be there, but recently I have
> been
> doing more with the web and CGI, and it's great to build software when you
> have
> a giant software chip library and are fairly familiar with it. Just a
> couple includes,
> a main() and you're done. The procedures below I use extensively, every
day
> and they sure help.
>
> Chris Tenaglia, tech analyst, jci
>
>
> #
> # parse a string into a list with respect to a delimiter
> #
> procedure parse(line,delims)
> static chars
> chars := &cset -- delims
> tokens := []
> line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
> return tokens
> end
>
> #
> # prompt for an input string
> #
> procedure input(prompt)
> writes(prompt)
> return read()
> end
>
> #
> # parse a cgi query string into a table
> #
> procedure cgiparse(text)
> parts := parse(text,'&')
> lookup:= table("n/a")
> every part := !parts do
> {
> var := parse(part,'=')[1]
> val := map(parse(part,'=')[2],"+"," ") | ""
> lookup[unurl(var)] := map(unurl(val),"\r"," ")
> }
> return lookup
> end
>
> #
> # error handler if program called wrong
> #
> procedure error()
> write("content-type: text/html")
> write("")
> write("<HTML>")
> write("<HEAD><TITLE>BAD CALL</TITLE></HEAD>")
> write("<BODY BGCOLOR=80000><font color=#ffffff>")
> write("<PRE><B>\n\n\n")
> write("PROGRAM CALLED INCORRECTLY")
> write("\n\n\n</B></PRE>")
> write("</body>")
> stop("</html>")
> end
>
> #
> # This procedure maps the wierd characters out of cgi query strings
> #
> procedure unurl(text)
> static hex
> initial {
> hex := table("")
> hex["0"] := 0 ; hex["1"] := 1 ; hex["2"] := 2 ; hex["3"] := 3
> hex["4"] := 4 ; hex["5"] := 5 ; hex["6"] := 6 ; hex["7"] := 7
> hex["8"] := 8 ; hex["9"] := 9 ; hex["a"] := 10; hex["A"] := 10
> hex["b"] := 11; hex["B"] := 11; hex["c"] := 12; hex["C"] := 12
> hex["d"] := 13; hex["D"] := 13; hex["e"] := 14; hex["E"] := 14
> hex["f"] := 15; hex["F"] := 15
> }
> work := map(text,"+"," ")
> cache := []
> every i := 1 to *work do if work[i] == "%" then put(cache,i)
> while i := pull(cache) do
> {
> nyb1 := work[i+1]
> nyb2 := work[i+2]
> if (nyb1 == "") | (nyb2 == "") then next
> raw := hex[nyb1] * 16 + hex[nyb2]
> byte := char(raw)
> work[i+:3] := byte
> }
> return work
> end
>
>
>